[id].vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 页面导航 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 广告1 -->
  7. <HomeAdvertising :imgurl="adImg1"></HomeAdvertising>
  8. <!-- 面包屑导航 -->
  9. <div class="breadcrumb">
  10. <div class="inner">
  11. <span class="location">当前位置:</span>
  12. <el-breadcrumb :separator-icon="ArrowRight">
  13. <el-breadcrumb-item>
  14. <NuxtLink to="/">首页</NuxtLink>
  15. </el-breadcrumb-item>
  16. <el-breadcrumb-item>
  17. <NuxtLink :to="{ path: `/newsList/${routLevelId}` }">
  18. {{ routLevelTitle }}
  19. </NuxtLink>
  20. </el-breadcrumb-item>
  21. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  22. </el-breadcrumb>
  23. </div>
  24. </div>
  25. <!-- 资讯列表 -->
  26. <div class="newsDetail">
  27. <div class="inner">
  28. <div class="innerLeft">
  29. <div class="LeftTop">
  30. <h1>{{ newsDetail.title }}</h1>
  31. <p>
  32. 来源: <span>{{ newsDetail.copyfrom }}</span>
  33. 作者: <span>{{ newsDetail.author }}</span>
  34. 发布时间: <span>{{ time }}</span>
  35. </p>
  36. </div>
  37. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content" @click="openPreview">
  38. </div>
  39. <div v-if="previewVisible" class="preview-modal" @click="closePreview">
  40. <img :src="selectedImage" alt="Preview">
  41. </div>
  42. <!-- 免责声明: -->
  43. <div class="disclaimer" v-if="newsDetail.fromurl">
  44. <p>原文链接:{{ newsDetail.fromurl }}</p>
  45. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  46. </div>
  47. </div>
  48. <div class="innerRight">
  49. <!-- 热点资讯1 -->
  50. <div class="hotList1">
  51. <DetailHotNews></DetailHotNews>
  52. </div>
  53. <!-- 热点资讯2 -->
  54. <div class="hotList2">
  55. <DetailHotNews2></DetailHotNews2>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <!-- 页面底部 -->
  61. <HomeFoot></HomeFoot>
  62. </template>
  63. <script setup>
  64. //1.页面依赖 start ---------------------------------------->
  65. import { onMounted } from 'vue'
  66. import { ElBreadcrumb, ElBreadcrumbItem} from 'element-plus'
  67. import { ArrowRight } from '@element-plus/icons-vue'
  68. //获得跳转过来的id
  69. const route = useRoute();
  70. const articleId = route.params.id; //获得该页面的id
  71. //1.页面依赖 end ---------------------------------------->
  72. //2.页面数据 start ---------------------------------------->
  73. //2.1 资讯详情
  74. const newsDetail = ref({})
  75. const routeNewsTtitle = ref("");
  76. //2.2 发布日期
  77. const time = ref("");
  78. //2.3 路径
  79. const routLevelTitle = ref("");
  80. const routLevelId = ref("");
  81. //是否展示投票
  82. const articleChoice = ref(false);
  83. //2.4获取详情
  84. async function getPageData() {
  85. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  86. method: 'GET',
  87. query: {
  88. 'articleid': articleId
  89. },
  90. });
  91. if (mkdata.code == 200) {
  92. //判断是否显示投票
  93. if (mkdata.data.is_survey == 1) {
  94. console.log("本篇文章含有投票!")
  95. articleChoice.value = true;
  96. getVoteList();
  97. }
  98. //获取内容
  99. newsDetail.value = mkdata.data;
  100. //获取路径
  101. routLevelTitle.value = newsDetail.value.cat_name;
  102. routLevelId.value = newsDetail.value.category_id;
  103. //获取发布时间
  104. time.value = newsDetail.value.updated_at.split(' ')[0];
  105. //修正标题长度
  106. if (newsDetail.value.title.length >= 30) {
  107. routeNewsTtitle.value = newsDetail.value.title.substr(0, 30) + "...";
  108. } else {
  109. routeNewsTtitle.value = newsDetail.value.title
  110. }
  111. } else {
  112. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  113. console.log("错误位置:获取详情内容")
  114. console.log("后端错误反馈:", mkdata.message)
  115. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  116. }
  117. }
  118. getPageData();
  119. //2.5 获得广告
  120. //广告列表
  121. let adImg1 = ref([]);
  122. // async function getAdData(){
  123. // const adData = await requestDataPromise('/web/getWebsiteAdvertisement',{method:'GET',query:{'ad_tag':'DETAIL'}});
  124. // if(adData.code==200){
  125. // for(let item of adData.data){
  126. // if(item.ad_tag == 'DETAIL_0001'){
  127. // adImg1.value = item;
  128. // }
  129. // }
  130. // }else{
  131. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  132. // console.log("错误位置:获取详情页广告列表")
  133. // console.log("后端错误反馈:",adData.message)
  134. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  135. // }
  136. // }
  137. // getAdData();
  138. onMounted(async () => {
  139. const { $webUrl, $CwebUrl } = useNuxtApp();
  140. //广告1
  141. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_detail_0001`
  142. const responseAd1 = await fetch(url, {
  143. headers: {
  144. 'Content-Type': 'application/json',
  145. 'Userurl': $CwebUrl,
  146. 'Origin': $CwebUrl
  147. }
  148. });
  149. const resultAd1 = await responseAd1.json();
  150. adImg1.value = resultAd1.data[0];
  151. })
  152. //2.页面数据 end ---------------------------------------->
  153. //3.设置seo信息 start---------------------------------------->
  154. //3.1 设置seo信息
  155. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  156. method: 'GET',
  157. query: {
  158. 'articleid': articleId
  159. },
  160. });
  161. if (setData.code == 200) {
  162. let seoTitle = setData.data.title;
  163. let seoDescription = setData.data.introduce;
  164. let seoKeywords = setData.data.keyword;
  165. let seoSuffix = setData.data.suffix;
  166. let seoName = setData.data.website_name;
  167. useSeoMeta({
  168. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  169. meta: [
  170. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  171. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  172. ]
  173. });
  174. } else {
  175. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  176. console.log("错误位置:设置详情页面SEO数据")
  177. console.log("后端错误反馈:", setData.message)
  178. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  179. }
  180. //3.设置seo信息 end---------------------------------------->
  181. //5.页面图片放大 start---------------------------------------->
  182. const previewVisible = ref(false)
  183. const selectedImage = ref(' ')
  184. const openPreview = (event) => {
  185. if (event.target.tagName === 'IMG') {
  186. selectedImage.value = event.target.src;
  187. previewVisible.value = true;
  188. }
  189. }
  190. const closePreview = () => {
  191. previewVisible.value = false;
  192. }
  193. //5.页面图片放大 end---------------------------------------->
  194. </script>
  195. <style lang="less" scoped>
  196. //导航条
  197. .breadcrumb {
  198. width: 100%;
  199. height: 22px;
  200. margin-bottom: 30px;
  201. margin-top: 40px;
  202. font-family: Microsoft YaHei, Microsoft YaHei;
  203. font-weight: 400;
  204. font-size: 20px;
  205. color: #666666;
  206. line-height: 23px;
  207. text-align: left;
  208. font-style: normal;
  209. text-transform: none;
  210. .el-breadcrumb::v-deep {
  211. display: inline-block;
  212. vertical-align: -4px;
  213. }
  214. /deep/.el-breadcrumb__inner a,
  215. /deep/.el-breadcrumb__inner.is-link {
  216. color: #666666;
  217. font-weight: 400;
  218. text-decoration: none;
  219. transition: var(--el-transition-color);
  220. }
  221. span {
  222. font-family: Microsoft YaHei, Microsoft YaHei;
  223. font-weight: 400;
  224. font-size: 20px;
  225. color: #666666;
  226. line-height: 23px;
  227. text-align: left;
  228. font-style: normal;
  229. text-transform: none;
  230. }
  231. span:hover {
  232. color: #666666;
  233. }
  234. .location {
  235. margin-right: 20px;
  236. width: 100px;
  237. height: 22px;
  238. font-family: Microsoft YaHei, Microsoft YaHei;
  239. font-weight: 400;
  240. font-size: 20px;
  241. color: #666666;
  242. line-height: 23px;
  243. text-align: left;
  244. font-style: normal;
  245. text-transform: none;
  246. }
  247. }
  248. // 资讯列表
  249. .newsDetail {
  250. width: 100%;
  251. //height: 1400px;
  252. margin-bottom: 70px;
  253. .inner {
  254. width: 1200px;
  255. //height: 1400px;
  256. overflow: hidden;
  257. font-size: 16px;
  258. .innerLeft {
  259. width: 810px;
  260. border-top: 1px solid #ccc;
  261. margin-right: 40px;
  262. .LeftTop {
  263. // height: 522px;
  264. margin-top: 50px;
  265. >h1 {
  266. line-height: 40px;
  267. margin-bottom: 30px;
  268. font-family: Microsoft YaHei, Microsoft YaHei;
  269. font-weight: bold;
  270. font-size: 30px;
  271. color: #333333;
  272. }
  273. >p {
  274. height: 18px;
  275. line-height: 18px;
  276. font-family: Microsoft YaHei, Microsoft YaHei;
  277. font-weight: 400;
  278. font-size: 14px;
  279. color: #999999;
  280. span {
  281. margin-right: 40px;
  282. }
  283. }
  284. >img {
  285. width: 680px;
  286. height: 382px;
  287. padding: 50px 0px 60px 55px;
  288. }
  289. }
  290. .leftBottom {
  291. width: 790px;
  292. margin-top: 50px;
  293. font-size: 20px;
  294. line-height: 38px;
  295. margin-bottom: 30px;
  296. ul>li img {
  297. width: 790px;
  298. height: 382px;
  299. }
  300. img {
  301. width: 790px;
  302. height: 382px;
  303. }
  304. p.tinymce-material {
  305. img {
  306. width: 790px;
  307. }
  308. }
  309. >h3,
  310. >p {
  311. text-indent: 2em;
  312. width: 790px;
  313. font-family: Microsoft YaHei, Microsoft YaHei;
  314. font-size: 20px;
  315. color: #333333;
  316. line-height: 38px;
  317. padding-bottom: 30px;
  318. img {
  319. width: 790px;
  320. }
  321. }
  322. >h3 {
  323. font-weight: 600px;
  324. }
  325. >p {
  326. font-weight: 400;
  327. }
  328. }
  329. .disclaimer {
  330. width: 790px;
  331. overflow: hidden;
  332. border-top: 1px solid #e6e6e6;
  333. padding: 30px 0px;
  334. color: #999999;
  335. font-size: 17px;
  336. p {
  337. width: 790px;
  338. line-height: 30px;
  339. }
  340. }
  341. }
  342. .innerRight {
  343. width: 350px;
  344. height: 1248px;
  345. border-top: 1px solid #ccc;
  346. border-bottom: 1px solid #ccc;
  347. }
  348. }
  349. }
  350. .leftBottom::v-deep p img,
  351. .leftBottom::v-deep img,
  352. .leftBottom::v-deep video {
  353. max-width: 700px;
  354. }
  355. .leftBottom::v-deep h1,
  356. .leftBottom::v-deep h2,
  357. .leftBottom::v-deep h3,
  358. .leftBottom::v-deep h4,
  359. .leftBottom::v-deep h5,
  360. .leftBottom::v-deep h6 {
  361. font-size: 20px;
  362. font-weight: 500;
  363. }
  364. //放大图片
  365. .preview-modal {
  366. position: fixed;
  367. top: 0;
  368. left: 0;
  369. width: 100%;
  370. height: 100%;
  371. background: rgba(0, 0, 0, 0.8);
  372. display: flex;
  373. justify-content: center;
  374. align-items: center;
  375. z-index: 1000;
  376. }
  377. .preview-modal img {
  378. max-width: 100%;
  379. max-height: 100%;
  380. cursor: pointer;
  381. /* 关闭按钮样式 */
  382. }
  383. </style>